<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <!-- <script src="http://localhost:8080"></script> -->
    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../../js/react.development.js"></script>
    <!-- 用于支持react操作DOM -->
    <script type="text/javascript" src="../../js/react-dom.development.js"></script>
    <!-- 用于将jsx转为js -->
    <script type="text/javascript" src="../../js/babel.min.js"></script>
</head>
<body>
    <div id="test"></div>
    <div id="test2"></div>

    <script type="text/javascript">
        let arr1 = [1,3,4,7]
        let arr2 = [2,5,6,8]
        // 展开数组
        console.log(...arr1);

        // 连接数组
        console.log([...arr1, ...arr2]);

        // 不定数量的参数
        function sum(...number){
            return number.reduce((pre, cur)=>{
                return pre + cur
            })
        }
        console.log(sum(...arr1));

        // 无法展开对象，但可以拷贝对象（非地址拷贝）
        let obj1 = {a:1, b:2}
        let obj2 = {...obj1}
        obj1.a = 2
        console.log(obj1);
        console.log(obj2);

        // 复制对象时修改属性
        let Obj1 = {a:1, b:2}
        let Obj2 = {...obj1, a:3}
        console.log(Obj2);

    </script>
</body>
<style>
</style>
</html>